<template>
	<view>
		<picker @change="bindPickerChange" :disabled="disabled" range-key="label" :range="range">
			<view class="uni-input">
				<text v-if="inputName&&inputName>-1">{{getName(inputName)}}</text>
				<text v-else class="placeholder">请选择</text>
				<uni-icons type="right" color="#999" size="16"></uni-icons>
			</view>
		</picker>
	</view>
</template>

<script>
	import {
		dictDataType,
	} from '@/api/commonTools'
	export default {
		model: {
			event: "inputFun",
		},
		props: ['inputName', "Radio", "disabled", 'isme'],
		data() {
			return {
				range: [],

			};
		},
		watch: {
			Radio(newVal) {}
		},
		mounted() {
			if (this.Radio) {
				this.dictDataType2(this.Radio, this.isme)
			}
		},
		methods: {
			dictDataType2(e, is) {
				dictDataType({
					type: e
				}).then(res => {
					this.range = res.data
					if (this.isme) {
						this.range.shift()
					}
				})
			},
			getName(e) {
				let item = this.range.find(i => i.value == e);
				return item.label;
			},
			bindPickerChange(e) {
				this.$nextTick(() => {
					this.$emit("inputFun", this.range[e.detail.value].value)
				})
			},
		}
	}
</script>

<style lang="less">
	.uni-input {
		display: flex;
		justify-content: right;
		align-items: center;
		height: 100%;
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: 500;

		.placeholder {
			color: #999;
		}
	}

	.uni-icons {
		position: relative;
		top: 1rpx;
	}
</style>